/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Random;

/**
 * <p>Project: javase202202 - Arr4
 * <p>Powered by Lisi On 2022-06-02 16:23:11
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class Arr4 {
    public static void main(String[] args) throws InterruptedException {
        //1-32 选6不能重复
        Random rand = new Random();
        int[] red = new int[32];
        int index = 0;
        int num = 0;
        while (true) {
            int temp = rand.nextInt(32) + 1;
            boolean f = true;
            for (int i = 0; i < index; i++) {
                ++num;
                if (temp == red[i]) {
                    f = false;
                    break;
                }
            }
            if (f) {
                red[index++] = temp;
                System.out.println(Arrays.toString(red));
                Thread.sleep(2000);
            }
            if (index >= red.length) {
                break;
            }
        }
        System.out.println(Arrays.toString(red));
        System.out.println("共循环" + num + "次");
    }
}
